/**
 * 
 */
package org.xlab.baseframework.test.platform.dao.impl;

import java.util.Date;
import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.xlab.baseframework.dao.impl.BaseDAOImpl;
import org.xlab.baseframework.exception.ObjectNotFoundException;
import org.xlab.baseframework.test.platform.dao.api.IBizTransactionLogDAO;
import org.xlab.baseframework.test.platform.domain.BizTransactionLog;
import org.xlab.baseframework.test.platform.domain.enumerate.SynchronizedInditify;

/**
 * @author makubex
 * 
 */
public class BizTransactionLogDAOImpl extends
		BaseDAOImpl<BizTransactionLog, Long> implements IBizTransactionLogDAO {

	/**
	 * @see org.xlab.baseframework.test.platform.dao.api.IBizTransactionLogDAO#findAllByCreatedTime(java.util.Date)
	 */
	public List<BizTransactionLog> findAllByMaxCreatedTime(Date maxCreatedTime)
			throws ObjectNotFoundException {
		List<BizTransactionLog> result = null;
		DetachedCriteria criteria = super.generateCriteria();
		criteria.add(Restrictions.le("createdTime", maxCreatedTime));
		criteria.add(Restrictions.ne("synchronizedInd", SynchronizedInditify.Y));
		result = super.findAllByCriteria(criteria);
		if (result == null || result.isEmpty()) {
			throw new ObjectNotFoundException();
		}
		return result;
	}

}
